
# 幼儿园报名数据
import requests
import json
import random
from threading import Thread, current_thread


def get_data_yey():
    url = 'http://wowblizzard.tw/login/zh/challenge.php?ae8a2aa4-ae66-41c3-90a2-ff42afdae3e0&ref=/login/zh/account-unlock&app=bam&sendCode=true'
    headers = {}
    # 从文件中读取headers信息
    with open('headers1.txt', 'r') as f:
        line = f.readline()
        while line:
            if line is not None:
                # print(line.strip())
                values = line.strip().split(':')
                headers[values[0]] = values[1]
            line = f.readline()

    vs = {}
    # 从文件中读取headers信息
    with open('vs.txt', 'r') as f:
        line = f.readline()
        while line:
            if line is not None:
                # print(line.strip())
                values = line.strip().split(':')
                vs[values[0]] = values[1]
            line = f.readline()

    vs['accountName'] = generate_random_str(random.randint(5,11))+'@'+generate_random_str(random.randint(3,7))+'.com'
    vs['password'] = generate_random_str(random.randint(5,11))

    # for kk in vs:
    #     print(vs[kk])
    # params = {'key1': 'value1', 'key2': 'value2'}

    response = requests.post(url=url, data=vs, headers=headers)
    # response.encoding = "utf-8"
    return response.text

def generate_random_str(randomlength=16):
    """
    生成一个指定长度的随机字符串
    """
    random_str =''
    base_str ='ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789'
    length =len(base_str) -1
    for i in range(randomlength):
        random_str +=base_str[random.randint(0, length)]
    return random_str


def target01(v1,v2):
    print('开始获取数据'+v2)
    for i in range(1, 500):
        data = get_data_yey()


if __name__ == '__main__':

    thread01 = Thread(target=target01, args="参数", name="线程1")
    thread01.start()
    thread02 = Thread(target=target01, args="参数", name="线程2")
    thread02.start()
    thread03 = Thread(target=target01, args="参数", name="线程3")
    thread03.start()
    thread04 = Thread(target=target01, args="参数", name="线程4")
    thread04.start()
    thread05 = Thread(target=target01, args="参数", name="线程5")
    thread05.start()
    thread06 = Thread(target=target01, args="参数", name="线程6")
    thread06.start()
    thread07 = Thread(target=target01, args="参数", name="线程7")
    thread07.start()
    thread08 = Thread(target=target01, args="参数", name="线程8")
    thread08.start()
    thread09 = Thread(target=target01, args="参数", name="线程9")
    thread09.start()
    thread010 = Thread(target=target01, args="参数", name="线程10")
    thread010.start()















    # print(data)
    # file_handle = open('1.html', mode='w', encoding='utf-8')
    # file_handle.write(data)
    # file_handle.close()


    # print(value['data']['list'])
